<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .heart i{
            width:20px;
            height:20px;
            display: block;
            background: url(images/sprites.png) no-repeat -120px -110px;
        }
        .cur{
            background: url(images/sprites.png) no-repeat -240px -110px!important;
        }
    </style>
</head>


<body>
    <div class="heart"><i></i>爱心</div>
	<script type="text/javascript">
		var io = document.querySelector('i');
		var flag = 0;
		io.onclick = function(){
			//alert(1);
			if(flag==0){
				io.className = 'cur';
				flag=1;
				//和后端交互数据
			}else{
				io.className = '';
				flag=0;
			}
		}
	</script>
</body>

</html>
